import type { AxiosResponse } from 'axios'
import axiosInstance from '@/utils/network/axios'

export async function axg_getUserTypeStatus(
    type: 'local' | 'virtual' | 'anonymous'
): Promise<boolean | string> {
    const response: AxiosResponse = await axiosInstance.get(`/home/user/type-control?type=${type}`)
    if (response.status === 200) {
        return response.data['status']
    } else {
        return response.data
    }
}

export interface UserListItem {
    username: string
    uid: number
    group: string
    home: string
    shell: string
}

export async function axg_getUserList(
    type: 'local' | 'virtual' | 'anonymous'
): Promise<Array<UserListItem>> {
    const response: AxiosResponse = await axiosInstance.get(`/home/user/list?type=${type}`)
    if (response.status === 200) {
        return response.data as Array<UserListItem>
    } else {
        return response.data
    }
}
